﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using ZhouYu.NewWorld.BLL.IService;
using ZhouYu.NewWorld.DAL;
using ZhouYu.NewWorld.Model;
using ZhouYu.NewWorld.ViewModel;

namespace ZhouYu.NewWorld.BLL.Service
{
    public class TourService : BaseRepository<Tour>, ITourService
    {
        public ResponseResult EditTour(Tour tour) 
        {
            //定义查询表达式
            Expression<Func<Tour, bool>> lambdaCategory = a => a.TourId == tour.TourId;
            //获取需要修改的对象
            Tour tours = Query(lambdaCategory);
            tours.UpdateTime = DateTime.Now;
            tours.Price = tour.Price;
            tours.Discount = tour.Discount;
            tours.StartPlace = tour.StartPlace;
            tours.EndPlace = tour.EndPlace;
            tours.TourDays = tour.TourDays;
            tours.RemanentDays = tour.RemanentDays;
            tours.StartTime = tour.StartTime;
            tours.EndTime = tour.EndTime;
            tours.DiscountPrice = tour.Price * Convert.ToDecimal(tour.Discount) / 10;
            //创建返回结果对象
            ResponseResult responseResult = new ResponseResult();
            //修改订单获取结果值
            responseResult.Success = Update(tours);
            return responseResult;
        }
    }
}
